package com.jack.controller;


import com.jack.pojo.OperateLog;
import com.jack.result.ClazzOption;
import com.jack.result.JobOption;
import com.jack.result.PageResult;
import com.jack.result.Result;
import com.jack.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class ReportController {

    @Autowired
    private ReportService reportService;

    /**
     * 统计各职位的员工人数
     * @return
     */
    @GetMapping("/report/empJobData")
    public Result getEmpJobData(){
        JobOption jobOption = reportService.getEmpJobData();
        return Result.success(jobOption);
    }

    /**
     * 统计员工性别
     * @return
     */
    @GetMapping("/report/empGenderData")
    public Result getEmpGenderData() {
        List<Map<String,Object>> list = reportService.getEmpGenderData();
        return Result.success(list);
    }

    /**
     * 学生学历统计
     * @return
     */
    @GetMapping("/report/studentDegreeData")
    public Result getStuDegreeData (){
        List<Map<String,Object>> list = reportService.getStuDegreeData();
        return Result.success(list);
    }

    /**
     * 班级人数统计
     * @return
     */
    @GetMapping("/report/studentCountData")
    public Result getStuCountOfClazzData(){
        ClazzOption clazzOption = reportService.getStuCountOfClazzData();
        return Result.success(clazzOption);
    }

    /**
     * 日志分页查询
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/log/page")
    public Result getLogs(Integer page, Integer pageSize){
        PageResult<OperateLog> logs = reportService.getLogs(page, pageSize);
        // TODO 前端操作人显示有问题，怀疑前端表格绑定的属性与后端不一致
        return Result.success(logs);
    }

}
